<template>
	<view>
		<uni-card title="用途">
			<view>大多数用于组件嵌套比较深时能够更加方便的通信，或者一个操作要通知给多个组件时能有统一的方式传递信息。</view>
		</uni-card>
		
		<uni-card title="介绍">
			<view>1.依赖：https://github.com/developit/mitt</view>
			<view>2.源代码位于：/common/utils/eventBus.js</view>
		</uni-card>
		
		<uni-card title="使用样例">
			<button
			  type="primary"
			  block
			  @tap="handleEventBusTest"
			>事件总线测试</button>
		</uni-card>
	</view>
</template>

<script>
	import { success } from '../../../common/utils/feedback'
	import eventBus from '../../../common/utils/eventBus'
	import { TEST_EVENT } from '../../../common/constant/eventNames'
	export default {
		data() {
			return {}
		},
		onLoad() {
			eventBus.on(TEST_EVENT, data => {
				success(`触发${data}`)
			})
		},
		methods: {
			handleEventBusTest () {
				eventBus.emit(TEST_EVENT, 'test event')
			}
		}
	}
</script>

<style></style>
